//
//  DBMan.h
//  microtv
//
//  Created by zhang jun on 12-3-23.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//
//此类是数据库的操作的核心类

#import <Foundation/Foundation.h>
#import "ToolOperation.h"

#import "FMDatabase.h"
#import "FMDatabaseAdditions.h"
#import "FMDatabasePool.h"
#import "FMDatabaseQueue.h"
#import "LoanHisUnit.h"
#import "MsgInfo.h"
//数据库名称
#define DBNAME @"CreditDB"


@interface DBMan : NSObject{
    
    NSMutableArray* tempArrSingle;
    FMDatabase* fmdb;
}

@property (nonatomic,retain)  FMDatabase* fmdb;


+(DBMan*)shareDB;


// 返回数据库的绝对路径
- (NSString *) databasePath;


//创建数据库
- (void) createDB;


//初始化数据库所有的表
-(void)initAllTableOfDB;

/*>>>>>>>>>>>>>>>>>>>>>问答>>>>>>>>>>>>>>>>>>>>>*/
//QuestionID数组
-(NSMutableArray*)getAllSectionQuesIDInQAInfo;

//根据问题ID获取当前ID下的答案
-(NSMutableArray*)getAllReplysByQuestionID:(NSString*)quesID;

//将问答结果保存
- (void)saveToQA:(MsgInfo *)msg;

//将答案进行更新（当收到第一个答案的时候）
- (BOOL)updateAnswer:(NSString *)answer byID:(NSString *)quesID;

//进入详细回答界面后要更新数据库的readflag字段
- (BOOL)updateReadFlagbyID:(NSString *)quesID;

//判断是否已经收到第一个答案（根据 isReply）
- (BOOL)isReplyByQuesID:(NSString *)quesID;
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/


//保存贷款历史
-(void)saveToLoanHis:(LoanHisUnit*)loanHis;


//保存新房税费历史
-(void)saveToNewTaxesHis:(TaxesNewHisUnit*)newHis;

//保存二手房税费历史
-(void)saveToSecondTaxesHis:(TaxesSecondHisUnit*)secondHis;


//更具日期获取当前日期下的计算数组
-(NSMutableArray*)getAllHistoryByTimeInLoanHist:(NSString*)timeStr;


-(NSMutableArray*)getAllHistoryByTimeInSecondTaxesHist:(NSString*)timeStr;


-(NSMutableArray*)getAllHistoryByTimeInNewTaxesHist:(NSString*)timeStr;


//Time section数组
-(NSMutableArray*)getAllSectionTimeInLoanHist;

-(NSMutableArray*)getAllSectionTimeInNewTaxesHist;

-(NSMutableArray*)getAllSectionTimeInSecondTaxesHist;

//获取所有数据字典
-(NSMutableDictionary*)getAllDicInLoanHist;

-(NSMutableDictionary*)getAllDicInNewTaxesHist;

-(NSMutableDictionary*)getAllDicInSecondTaxesHist;
@end